package com.fire.control.system.module.device.controller.web;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.fire.control.system.dto.UserDTO;
import com.fire.control.system.module.common.controller.BaseController;
import com.fire.control.system.module.device.service.DeviceService;
import com.fire.control.system.standard.BusinessInterfaceStandard;
import com.fire.control.system.support.protocol.comman.ResponseProtocol;
import com.fire.control.system.support.protocol.device.DeviceRequestProtocol;


/**
 * 
 * @ClassName:  DeviceManagementController
 * @Description:  设备管理控制器
 * @author:  xiechengguang
 * @date:  2017年5月5日 下午6:18:14
 *
 */
@RestController
@RequestMapping(value="/web/device")
public class DeviceManagementController extends BaseController implements BusinessInterfaceStandard<DeviceRequestProtocol,ResponseProtocol>{
	private static final Logger log = LoggerFactory.getLogger(DeviceManagementController.class);
	@Autowired 
	private DeviceService deviceService;
	
	
	
	/**
	 * 
	 * @Title: getDeviceList   
	 * @Description: 获取设备列表  
	 * @param:  requestProtocol     
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/getDeviceList", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol getDeviceList(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.getDeviceList(requestProtocol);
	}
	
	/**
	 * 
	 * @Title: getDeviceInfo   
	 * @Description: 获取设备详细信息  
	 * @param:  requestProtocol      
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/getDeviceInfo", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol getDeviceInfo(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.getDeviceInfo(requestProtocol);
	}
	
	/**
	 * 
	 * @Title: updateDeviceInfo   
	 * @Description: 修改设备信息  
	 * @param:  requestProtocol      
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/updateDeviceInfo", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol updateDeviceInfo(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.updateDeviceInfo(requestProtocol);
	}
	
	/**
	 * 
	 * @Title: deleteDevice   
	 * @Description: 删除一个或一组设备  
	 * @param:  requestProtocol     
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/deleteDevice", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol deleteDevice(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.deleteDevice(requestProtocol);
	}
	
	/**
	 * 
	 * @Title: searchDevices   
	 * @Description: 按条件搜索设备列表  
	 * @param:  requestProtocol      
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/searchDevices", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol searchDevices(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.searchDevices(requestProtocol, getUser());
	}
	
	
	/**
	 * 
	 * @Title: addDevice   
	 * @Description: 新增设备  
	 * @param:  requestProtocol      
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/addDevice", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol addDevice(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.addDevice(requestProtocol);
	}
	
	/**
	 * 
	 * @Title: getDeviceGroupList   
	 * @Description: 获取设备组列表  
	 * @param:  requestProtocol      
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/getDeviceGroupList", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol getDeviceGroupList(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.getDeviceGroupList(requestProtocol, getUser());
	}
	
	/**
	 * 
	 * @Title: updateDeviceGroupInfo   
	 * @Description: 修改设备组信息  
	 * @param:  requestProtocol      
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/updateDeviceGroupInfo", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol updateDeviceGroupInfo(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.updateDeviceGroupInfo(requestProtocol, getUser());
	}
	
	/**
	 * 
	 * @Title: deleteDeviceGroup   
	 * @Description: 删除设备组  
	 * @param:  requestProtocol      
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/deleteDeviceGroup", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol deleteDeviceGroup(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.deleteDeviceGroup(requestProtocol);
	}
	
	/**
	 * 
	 * @Title: searchDeviceGroups   
	 * @Description: 搜索设备组  
	 * @param:  requestProtocol      
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/searchDeviceGroups", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol searchDeviceGroups(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.searchDeviceGroups(requestProtocol, getUser());
	}
	
	/**
	 * 
	 * @Title: getDeviceGroupInfo   
	 * @Description: 根据id获取设备组详细  
	 * @param:  requestProtocol     
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/getDeviceGroupInfo", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol getDeviceGroupInfo(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.getDeviceGroupInfo(requestProtocol);
	}
	
	/**
	 * 
	 * @Title: addDeviceGroup   
	 * @Description: 新增设备组  
	 * @param:  requestProtocol     
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/addDeviceGroup", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol addDeviceGroup(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.addDeviceGroup(requestProtocol, getUser());
	}
	
	/**
	 * 
	 * @Title: getDeviceMaintenceList   
	 * @Description: 维保设备列表
	 * @param:  requestProtocol      
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/getDeviceMaintenceList", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol getDeviceMaintenceList(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.getDeviceMaintenceList(requestProtocol, getUser());
	}
	
	/**
	 * 
	 * @Title: getDeviceMaintenceInfo   
	 * @Description: 维保设备处理详细信息  
	 * @param:  requestProtocol      
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/getDeviceMaintenceInfo", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol getDeviceMaintenceInfo(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.getDeviceMaintenceInfo(requestProtocol, getUser());
	}
	
	/**
	 * 
	 * @Title: deleteDeviceMaintence   
	 * @Description: 删除维保设备信息  
	 * @param:  requestProtocol      
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/deleteDeviceMaintence", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol deleteDeviceMaintence(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.deleteDeviceMaintence(requestProtocol);
	}
	
	/**
	 * 
	 * @Title: handleDeviceMaintence   
	 * @Description: 维保处理  
	 * @param:  requestProtocol      
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/handleDeviceMaintence", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol handleDeviceMaintence(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.handleDeviceMaintence(requestProtocol, getUser());
	}
	
	/**
	 * 
	 * @Title: searchDeviceMaintences   
	 * @Description: 按条件搜索维保设备列表  
	 * @param:  requestProtocol      
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/searchDeviceMaintences", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol searchDeviceMaintences(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.searchDeviceMaintences(requestProtocol, getUser());
	}
	
	/**
	 * 
	 * @Title: getDevicesByTreeId   
	 * @Description: 根据省、市、区、设备组获取其下的对应设备
	 * @param:  requestProtocol      
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/getDevicesByTreeId", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol getDevicesByTreeId(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.getDevicesByTreeId(requestProtocol, getUser());
	}
	
	
	/**
	 * 
	 * @Title: getAllBuildingDevices   
	 * @Description: 根据设备id获取其所在楼栋的所有设备
	 * @param:  requestProtocol      
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/getAllBuildingDevices", method=RequestMethod.POST)
	@ResponseBody
	public ResponseProtocol getAllBuildingDevices(DeviceRequestProtocol requestProtocol) {
		
		return deviceService.getAllBuildingDevices(requestProtocol, getUser());
	}
	
}
